<%@page import="java.util.Date" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@include file="/WEB-INF/jsp/common/head.jsp" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<div class="right">
    <div class="location">
        <strong>你现在所在的位置是:</strong>
        <span>收件箱页面</span>
    </div>
    <!--用户-->
    <table class="providerTable" cellpadding="0" cellspacing="0">
        <tr class="firstTr">
            <th width="10%">发件人</th>
            <th width="20%">主题</th>
            <th width="10%">文件名</th>
            <th width="10%">文件密级</th>
            <th width="10%">是否已读</th>
            <th width="10%">时间</th>
            <th width="20%">操作</th>
        </tr>
        <c:forEach var="doc" items="${documents }" varStatus="status">
            <tr>
                <td>
                    <span>${doc.sendUser}</span>
                </td>
                <td>
                    <span>${doc.title}</span>
                </td>
                <td>
                    <span>${doc.fileName}</span>
                </td>
                <td>
                    <c:choose>
                        <c:when test="${doc.fileLevel == 0 }">
                            <span>普通</span>
                        </c:when>
                        <c:when test="${doc.fileLevel == 1 }">
                            <span>秘密</span>
                        </c:when>
                        <c:when test="${doc.fileLevel == 2 }">
                            <span>机密</span>
                        </c:when>
                        <c:otherwise>
                            <span>绝密</span>
                        </c:otherwise>
                    </c:choose>
                </td>
                <td>
                    <c:choose>
                        <c:when test="${doc.read == false }">
                            <span>未读</span>
                        </c:when>
                        <c:otherwise>
                            <span>已读</span>
                        </c:otherwise>
                    </c:choose>
                </td>
                <td>
                    <span>${doc.time}</span>
                </td>
                <td>
                    <span><a class="downDocument" docid=${doc.id } filepath=${doc.filePath }>下载</a></span>
                </td>
            </tr>
        </c:forEach>
    </table>
</div>
</section>

<%@include file="/WEB-INF/jsp/common/foot.jsp" %>

<script>
    $(function() {
        $(".downDocument").on("click", function () {
            //将被绑定的元素（a）转换成jquery对象，可以使用jquery方法
            var obj = $(this);
            window.open("/eDocTrans/down?file=" + obj.attr("filepath") + "&id=" + obj.attr("docid"), "_blank");
            location.reload();
        });
    });

</script>
